<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
%>
<jsp:include page="/comm/header.jsp" />
<jsp:include page="/comm/menu.jsp" />
<script type="text/javascript">
<!--
$(function(){
	$("#pwd1").focus(function(){
		$("#pwd1Tip").html("<font>6-16位字母、数字，不支持空格</font>");
	}); 
	$("#pwd2").focus(function(){
		$("#pwd2Tip").html("<font>请再次输入密码，两次输入必须一致</font>");
	}); 
	
	$("#pwd1").blur(validPwd1);
	$("#pwd2").blur(validPwd2);
	$("#but_submit").click(doSubmit);
	
	$("#pwd2").bind('keyup',function(event) {
		if(event.keyCode==13){
			doSubmit();
		}
	});
});

var doSubmit = function(){
	var x = validPwd1();
	var y = validPwd2();
	if(x && y){
		document.form1.action = "modifypwd.htm";
		document.form1.submit(); 
	}
};

var validPwd1 =  function(){
	var pwd = $("#pwd1").val();
	if(!pwd){
		$("#pwd1Tip").html("<img src='<%=path%>/images/no.gif'/><font color='red'>不能为空</font>");
		return false;
	}else{
		var reg = /^\d+$/;
		if(reg.test(pwd)){
			$("#pwd1Tip").html("<img src='<%=path%>/images/no.gif'/><font color='red'>不能全为数字</font>");
			return false;
		}else{
			var reg = /^[A-Za-z]*$/;
			if(reg.test(pwd)){
				$("#pwd1Tip").html("<img src='<%=path%>/images/no.gif'/><font color='red'>不能全为字母</font>");
				return false;
			}
		}
		
		if(pwd.search(/^\s+$/) != -1){
			$("#pwd1Tip").html("<img src='<%=path%>/images/no.gif'/><font color='red'>不能包含非法字符</font>");
			return false;
		}
		
		if(pwd.length > 5 && pwd.length < 17){
			$("#pwd1Tip").html("<img src='<%=path%>/images/yes.gif'/>");
			return true;
		}else{
			$("#pwd1Tip").html("<img src='<%=path%>/images/no.gif'/><font color='red'>密码必须为6-16位字符</font>");
			return false;
		}
		
	}
};

var validPwd2 = function(){
	var pwd1 = $("#pwd1").val();
	var pwd2 = $("#pwd2").val();
	if(!validPwd1()){
		$("#pwd2Tip").html("");
		return false;
	}
	if(!pwd2){
		$("#pwd2Tip").html("<img src='<%=path%>/images/no.gif'/><font color='red'>再输一次密码</font>");
		return false;
	}else{
		if(pwd1 ==  pwd2){
			$("#pwd2Tip").html("<img src='<%=path%>/images/yes.gif'/>");
			return true;
		}else{
			$("#pwd2Tip").html("<img src='<%=path%>/images/no.gif'/><font color='red'>两次密码输入不一致</font>");
			return false;
		}
	}
};
	
//-->
</script>

<div class="clear"></div>

<!--第1部分开始  --> 
    <div class="wrap1">
    	<div class="blank1"></div>
        
    	<div class="outbox3">
        	<div class="tab7_tt">忘记密码</div>
        	<form name="form1" method="post">
        	<input type="hidden" name="userModel.email" value="${email}"/>
        	<div class="input_box">
				<ul>
		        <li class="t1"><span class="span33">设置新密码：</span></li>
		        <li class="t2"><input id="pwd1" name="userModel.password" type="password" class="input1" maxlength="16"/>&nbsp;&nbsp;<span id="pwd1Tip"></span></li>
		        <li class="t1"><span class="span33">确认新密码：</span></li>
		        <li class="t2"><input id="pwd2" type="password" class="input1" maxlength="16"/>&nbsp;&nbsp;<span id="pwd2Tip"></span></li>
		    	</ul>
			</div>
			<div class="clear"></div>
			<div class="login_but" style="text-align:center; margin:20px 0;margin-left:-460px;"><input type="button" class="login" id="but_submit" value="确认修改" style="cursor:pointer"/>&nbsp;&nbsp;&nbsp;</div>
			</form>
			<div class="tips1"><span><b>安全提醒：</b>请妥善保管密码！代购岛工作人员不会以任何理由向您索取密码。</span></div>

      	</div>

    </div>
<!--第1部分结束  --> 
<jsp:include page="/comm/bottom.jsp" />
